<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script>
  let objs = {
    name:'zhangsan',
    password:'123456'
  }
  Object.defineProperty(objs,'name',{
    writable:true
  });
  let proxy=new Proxy(objs,{
    set(target,key,value){
      let isSuccess=Reflect.set(target,key,value);
      if(!isSuccess){
        throw new Error('值设置失败');
      }
      return isSuccess
    }
  })
  proxy.name = 18;
  proxy.password = 11222
  console.log(objs);
</script>
</body>
</html>